package com.spring.demo.springdemo.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.SmartLifecycle;
import org.springframework.stereotype.Component;

/**
 * @Author RenPu
 * @Date 2024/2/17 16:06
 * @Version 1.0
 * @Description:  实现对spring 《容器得生命周期》进行（监测）
 **/

@Slf4j
@Component
public class ContainerLifeListerner implements SmartLifecycle {


    private volatile boolean isRunning;


    @Override
    public void start() {
        this.isRunning=true;
        log.info("Spring Container is START ！！！！！");
    }

    @Override
    public void stop() {
        log.info("Spring Container is STOP ！！！！！");

    }

    @Override
    public boolean isRunning() {
        return isRunning;
    }
}
